#!/usr/bin/python
# Splits a fastq file into multiple.
import sys
import os

# parameters.
fasta_file = sys.argv[1]
filter_file = sys.argv[2]

# read in filter.
filters = {}
fin = open(filter_file, "rb")
for line in fin:
	filters[line.strip()] = True
fin.close()
	
# filter fasta.
first = True
fin = open(fasta_file, "rb")
for line in fin:
	# check if we start new entry.
	if line[0] == ">":
		# tally.
		if first != True:
			# See if we keep this read.
			if head in filters:
				print ">%s" % head
				print "%s" % seq	
		else:
			first = False
			
		# clear.
		head = line.strip().replace(">","")
		seq = ""
		continue
	
	
	# get only seq.
	seq += line.strip()
fin.close()

# get last.
if head in filters:
	print ">%s" % head
	print "%ss" % seq	

